﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Md5Tool
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void ButtonEnCoding_Click(object sender, EventArgs e)
		{
			string str = this.textBox1.Text;
			
			if (string.IsNullOrEmpty(str))
				return;
			this.textBox2.Text = MD5.HashString(str);
		}

		private void textBox1_TextChanged(object sender, EventArgs e)
		{
			this.ButtonEnCoding.Enabled = this.textBox1.Text.Length > 0;
		}

		private void ButtonCopy_Click(object sender, EventArgs e)
		{
			if (this.textBox2.Text.Length < 1)
				return;
			try
			{
				Clipboard.SetText(this.textBox2.Text);
				MessageBox.Show("复制成功！");				
			}
			catch (Exception)
			{
				MessageBox.Show("复制失败，请手工复制！");				
			}
		}
	}
}
